<style>
    .description { color: #999; font-size: 13px; }
    .send-item-list li, .send-pet-list li { margin: 8px 0; }
    .send-item-list li .form-control, .send-pet-list li .form-control { margin-right: 2px; }
    .tools-btn { padding: 5px 7px; border-radius: 12px; }
    .div_item_name{float: left;}
    .div_item_id{float: left;}
    form{margin-bottom: 300px;}
</style>
<form method="post" action="/oss/?r=giftBag/doAdd">
    <{include file='../common_params.tpl'}>

    <div class="box box-black">
        <div class="box-body">
            <table class="table table-bordered">
                <colgroup>
                    <col style="width: 20%;"></col>
                    <col style="width: 80%;"></col>
                </colgroup>
                
                
                <tr>
                    <th class="th-label">礼包种类</th>
                    <td>
                        <select class="form-control" name="classify" style="width: 150px;">
                            <{foreach from=$classifyList item=item key=key}>
                        		<option value="<{$key}>"><{$item}></option>
                        	<{/foreach}>
                        </select>
                    </td>
                </tr>
                
                <tr class="type-info" for="1">
                    <th class="th-label">礼包名称</th>
                    <td>
                        <input type="text" class="form-control inline" style="width: 150px;" name="bag_name" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">礼包描述</th>
                    <td><textarea class="form-control" name="bag_desc" rows="10"></textarea></td>
                </tr>
                
                <{include file="tpl/send_item.tpl"}>  
                
                
                
                <!--<tr class="attach-info" for="1">
                    <th class="th-label">礼包物品</th>
                    <td>
                        <ul class="nav send-item-list">
                            <li>
                                <input name="item_name[]" class="form-control inline" placeholder="名称" size="12"/>
                                <input type="text" name="item_number[]" class="form-control inline" placeholder="数量" size="5" />
                                <input type="text" name="item_color[]" class="form-control inline" placeholder="颜色" size="5" />
                                <select class="form-control inline" name="is_bind[]">
                                	<option value="1">绑定</option>
                                	<option value="0">不绑定</option>
                                </select>

                                <div class="box-tools inline">
                                    <a href="javascript:;" class="tools-btn tools-btn-add badge bg-green"><i class="fa fa-plus"></i></a>
                                    <a href="javascript:;" class="tools-btn btn-del badge bg-red"><i class="fa fa-minus"></i></a>
                                </div>
                            </li>                           
                        </ul> 
                    </td>
                </tr>-->

                

            </table>
        </div>

        <div class="box-footer">
            <a href="javascript:history.go(-1);" class="btn btn-default">返回</a>            
            <button type="submit" name="sub" class="btn btn-default pull-right">保存</button>
        </div>
    </div>
    
    
    
    
</form>


<script type="text/javascript">
    $(function(){
        var nameflag = true;
        var idflag = true;
        var numberflag = true;
        $('button[name="sub"]').click(function(){      	
        	
        	var bag_name = $('input[name="bag_name"]').val();
        	if(bag_name == ''){
        		layer.alert('请填写礼包名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}

        	$('input[name="item_name[]"]').each(function (i){
        		if($(this).val() == ''){
        			nameflag = false;
        		}else{
        			nameflag = true;
        		}
            });
            
            if(!nameflag){
            	layer.alert('请填写道具名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }

            $('input[name="item_id[]"]').each(function (i){
        		if($(this).val() == ''){
        			idflag =  false;
        		}else{
        			idflag = true;
        		}
            });
            
            if(!idflag){
            	layer.alert('请填写道具ID', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }
            
            $('input[name="item_number[]"]').each(function (i){
            	var max_overlap = $(this).attr('data-max');
            	_sthis = $(this);
		        var num = $(this).val();
        		if($(this).val() == ''){
        			numberflag = false;
        		}else if(parseInt(num) > parseInt(max_overlap)){
        			_sthis.val(max_overlap);
        		}else{
        			numberflag = true;
        		}
            });
            
            if(!numberflag){
            	layer.alert('请填写道具数量', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }

        });
    });
</script>